#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;

int q[N];

LL res;

int n, m;

int main()
{
	scanf("%d%d", &n, &m);
	
	for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);
	
	sort(q, q + n);
	
	for (int i = 0; i < m; i ++ )
	{
		int v;
		scanf("%d", &v);
		
		int l = 0, r = n - 1;
		
		while (l < r)
		{
			int mid = l + r >> 1;
			if (q[mid] >= v) r = mid;
			else l = mid + 1;
		}
		
		if (l != 0) res += min(abs(q[l] - v), abs(q[l - 1] - v));
		else res += q[0] - v;
	}
	
	printf("%lld", res);
	
	return 0;
}